package com.tianqu.tms.www.user.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.www.user.actionform.UserInputActionForm;
import com.tianqu.tms.www.user.viewhelper.UserPwdDetailViewhelper;

/**
 * 修改密码确认页
 * 
 * @author tianshifu
 *
 */

public class UserPasswordConfirmAction extends TmsAction {
	
	private Logger logger = Logger.getLogger(UserPasswordConfirmAction.class);
	
	private static final String ID = "id";
	
	private static final String VIEW = "view";
		
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		//跳到这个之前需要对密码进行check
		
		UserInputActionForm psConfirmForm = (UserInputActionForm)form;
		
		
		String pp = (String) uc.getAttribute(ID);
			
		UserPwdDetailViewhelper viewhelper = new UserPwdDetailViewhelper();
		
		viewhelper.setId(pp);
				
		viewhelper.setNew_password(psConfirmForm.getNew_password());
		
		uc.setAttribute(TmsConstants.VIEWHELP, viewhelper);
		
		request.setAttribute(TmsConstants.VIEWHELP, viewhelper);
		
		//将form里的值放到viewhelp中
		logger.debug(this.getClass().getName() + "#doAction was completed.");
		
		return mapping.findForward(TmsConstants.SUCCESS);
	}

}
